package com.thread;

/**
 * @author liliang
 * @date 2019/12/19.
 */
public class CurrentThreadTest {

    public static void main(String[] args) {
        new CurrentThreadTest().shareMethod();
        new Thread(new Runnable() {
            @Override
            public void run() {
                new CurrentThreadTest().shareMethod();
            }
        }, "t1").start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                new CurrentThreadTest().shareMethod();
            }
        }, "t2").start();
    }

    public void shareMethod() {
        Thread thread = Thread.currentThread();
        System.out.println("当前执行的线程名:" + thread.getName());
    }
}
